package servlet.recipe.page;

import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import servlet.account.control.InfoCheck;
import servlet.recipe.control.Recipe_rsp;

import java.io.IOException;

@WebServlet("/Hot")
public class Hot extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String keyword=req.getParameter("keyword");
        InfoCheck ifc=new InfoCheck();
        if (ifc.checkCredentials(req)){req.setAttribute("Login","Session");}
        req.setAttribute("title","热门菜谱");
        Recipe_rsp rsq=new Recipe_rsp();
        req.setAttribute("recipes",rsq.cheackRecipesNull(rsq.recipes_rsp(2,keyword)));
        req.getRequestDispatcher("chushi/jsp/select.jsp").forward(req,resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req, resp);
    }
}
